package com.example.evanproject.controller;


import com.example.evanproject.domain.User;
import com.example.evanproject.service.impl.UserServiceImpl;
import com.example.evanproject.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/loginadmin")
public class UerController {

    @Autowired
    private UserServiceImpl userService;
    @RequestMapping("/user")
    public User selectinfo(Integer id){

        return userService.selectinfo(id);
    }

    @RequestMapping("login")
    public AjaxResult login(String name, String pass){

        return AjaxResult.success(userService.login(name,pass));
    }


    @RequestMapping("selectlist")
    public AjaxResult selectlist(){

        return AjaxResult.success(userService.selectlist()) ;
    }

//    修改账号或密码
    @RequestMapping("updatelist")
    public AjaxResult updatelist(Integer id,String name,String pass){
        System.out.println(id);
        System.out.println(name);
        System.out.println(pass);
      return AjaxResult.success(userService.updatelist(id,name,pass)) ;
    }
}
